﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Furion.CMS.Domain
{
    /// <summary>
    /// 黑名单
    /// </summary>
    [SuppressChangedListener]
    public class Blacklist : Entity, IEntityTypeBuilder<Blacklist>
    {
        public Blacklist()
        {
            this.CreatedTime = DateTimeOffset.UtcNow;
        }

        /// <summary>
        /// 主机地址
        /// </summary>
        [MaxLength(100), Required]
        public string HostAddress { get; set; }

        /// <summary>
        /// 描述信息
        /// </summary>
        [MaxLength(400)]
        public string Description { get; set; }

        public void Configure(EntityTypeBuilder<Blacklist> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder.UseDefaultTableNameDefine();

            entityBuilder.HasIndex(p => p.HostAddress);
        }
    }
}
